package com.ruoyi.web.controller.kycinfo;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.kycinfo.domain.KycPerfection;
import com.ruoyi.kycinfo.service.IKycPerfectionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 完善度信息Controller
 *
 * @author wzk
 * @date 2023-10-10
 */
@RestController
@RequestMapping("/kycinfo/perfection")
public class KycPerfectionController extends BaseController
{
    @Autowired
    private IKycPerfectionService kycPerfectionService;

    /**
     * 查询完善度信息列表
     */
    @PreAuthorize("@ss.hasPermi('kycinfo:perfection:list')")
    @GetMapping("/list")
    public TableDataInfo list(KycPerfection kycPerfection)
    {
        startPage();
        List<KycPerfection> list = kycPerfectionService.selectKycPerfectionList(kycPerfection);
        return getDataTable(list);
    }

    /**
     * 导出完善度信息列表
     */
    @PreAuthorize("@ss.hasPermi('kycinfo:perfection:export')")
    @Log(title = "完善度信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, KycPerfection kycPerfection)
    {
        List<KycPerfection> list = kycPerfectionService.selectKycPerfectionList(kycPerfection);
        ExcelUtil<KycPerfection> util = new ExcelUtil<KycPerfection>(KycPerfection.class);
        util.exportExcel(response, list, "完善度信息数据");
    }

    /**
     * 获取完善度信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('kycinfo:perfection:query')")
    @GetMapping(value = "/{perfectionId}")
    public AjaxResult getInfo(@PathVariable("perfectionId") Long perfectionId)
    {
        return success(kycPerfectionService.selectKycPerfectionByPerfectionId(perfectionId));
    }

    /**
     * 新增完善度信息
     */
    @PreAuthorize("@ss.hasPermi('kycinfo:perfection:add')")
    @Log(title = "完善度信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody KycPerfection kycPerfection)
    {
        return toAjax(kycPerfectionService.insertKycPerfection(kycPerfection));
    }

    /**
     * 修改完善度信息
     */
    @PreAuthorize("@ss.hasPermi('kycinfo:perfection:edit')")
    @Log(title = "完善度信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody KycPerfection kycPerfection)
    {
        return toAjax(kycPerfectionService.updateKycPerfection(kycPerfection));
    }

    /**
     * 删除完善度信息
     */
    @PreAuthorize("@ss.hasPermi('kycinfo:perfection:remove')")
    @Log(title = "完善度信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{perfectionIds}")
    public AjaxResult remove(@PathVariable Long[] perfectionIds)
    {
        return toAjax(kycPerfectionService.deleteKycPerfectionByPerfectionIds(perfectionIds));
    }
}
